//
//  TWSNavigationController.m
//  TWSWeibo
//
//  Created by Twisal on 2016/12/27.
//  Copyright © 2016年 Twisal. All rights reserved.
//

#import "TWSNavigationController.h"
#import "TWSBaseViewController.h"

@interface TWSNavigationController ()

@end

@implementation TWSNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.hidden = YES;
}


#pragma mark - Navigation
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    NSUInteger count = self.childViewControllers.count;
    NSLog(@"当前导航控制器中子控制器的数目为: %zd", count);
    NSLog(@"%@", self.viewControllers.firstObject.title);
    if (count > 0) {
        TWSBaseViewController *vc = (TWSBaseViewController *)viewController;
        viewController.hidesBottomBarWhenPushed = YES;
        NSString *title = @"返回";
        if (count == 1) {
            title = self.childViewControllers.firstObject.title;
        }
//        self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTitle:title target:self action:@selector(popToParentVc) isBack:YES];
//
        vc.naviItem.leftBarButtonItem = [UIBarButtonItem itemWithTitle:title target:self action:@selector(popToParentVc) isBack:YES];
        
    }
    [super pushViewController:viewController animated:animated];
}


- (void)popToParentVc {
    [self popViewControllerAnimated:YES];
}

@end
